﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        int i = 0, rd, cnt = 0, a = 0;
       
    
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Interval += 5;
            if (a % 2 == 0)
            {
                switch (cnt)
                {
                    case 0: pictureBox1.Size = new Size(120, 120); pictureBox1.Location = new Point(pictureBox1.Location.X - 10, pictureBox1.Location.Y - 10); break;
                    case 1: pictureBox2.Size = new Size(120, 120); pictureBox2.Location = new Point(pictureBox2.Location.X - 10, pictureBox2.Location.Y - 10); break;
                    case 2: pictureBox3.Size = new Size(120, 120); pictureBox3.Location = new Point(pictureBox3.Location.X - 10, pictureBox3.Location.Y - 10); break;
                    case 3: pictureBox4.Size = new Size(120, 120); pictureBox4.Location = new Point(pictureBox4.Location.X - 10, pictureBox4.Location.Y - 10); break;
                    case 4: pictureBox5.Size = new Size(120, 120); pictureBox5.Location = new Point(pictureBox5.Location.X - 10, pictureBox5.Location.Y - 10); break;
                    case 5: pictureBox6.Size = new Size(120, 120); pictureBox6.Location = new Point(pictureBox6.Location.X - 10, pictureBox6.Location.Y - 10); break;
                    case 6: pictureBox7.Size = new Size(120, 120); pictureBox7.Location = new Point(pictureBox7.Location.X - 10, pictureBox7.Location.Y - 10); break;
                    case 7: pictureBox8.Size = new Size(120, 120); pictureBox8.Location = new Point(pictureBox8.Location.X - 10, pictureBox8.Location.Y - 10); break;
                    case 8: pictureBox9.Size = new Size(120, 120); pictureBox9.Location = new Point(pictureBox9.Location.X - 10, pictureBox9.Location.Y - 10); break;
                    case 9: pictureBox10.Size = new Size(120, 120); pictureBox10.Location = new Point(pictureBox10.Location.X - 10, pictureBox10.Location.Y - 10); break;
                    default: break;
                }
                
                a++;
            }
            else if (a % 2 == 1)
            {
                switch (cnt)
                {
                    case 0: pictureBox1.Size = new Size(100, 100); pictureBox1.Location = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y + 10); break;
                    case 1: pictureBox2.Size = new Size(100, 100); pictureBox2.Location = new Point(pictureBox2.Location.X + 10, pictureBox2.Location.Y + 10); break;
                    case 2: pictureBox3.Size = new Size(100, 100); pictureBox3.Location = new Point(pictureBox3.Location.X + 10, pictureBox3.Location.Y + 10); break;
                    case 3: pictureBox4.Size = new Size(100, 100); pictureBox4.Location = new Point(pictureBox4.Location.X + 10, pictureBox4.Location.Y + 10); break;
                    case 4: pictureBox5.Size = new Size(100, 100); pictureBox5.Location = new Point(pictureBox5.Location.X + 10, pictureBox5.Location.Y + 10); break;
                    case 5: pictureBox6.Size = new Size(100, 100); pictureBox6.Location = new Point(pictureBox6.Location.X + 10, pictureBox6.Location.Y + 10); break;
                    case 6: pictureBox7.Size = new Size(100, 100); pictureBox7.Location = new Point(pictureBox7.Location.X + 10, pictureBox7.Location.Y + 10); break;
                    case 7: pictureBox8.Size = new Size(100, 100); pictureBox8.Location = new Point(pictureBox8.Location.X + 10, pictureBox8.Location.Y + 10); break;
                    case 8: pictureBox9.Size = new Size(100, 100); pictureBox9.Location = new Point(pictureBox9.Location.X + 10, pictureBox9.Location.Y + 10); break;
                    case 9: pictureBox10.Size = new Size(100, 100); pictureBox10.Location = new Point(pictureBox10.Location.X + 10, pictureBox10.Location.Y + 10); break;
                    default: break;
                }
                
                cnt++;
                a++;
            }
            if (cnt > 9)
            {
                cnt = 0;
            }
            if (a > rd && a % 2 == 1)
            {
                a = 0;
                timer1.Enabled = false;

                switch (cnt)
                {
                    case 0: MessageBox.Show("恭喜一等奖"); break;
                    case 1: MessageBox.Show("恭喜2等奖"); break;
                    case 2: MessageBox.Show("恭喜3等奖"); break;
                    case 3: MessageBox.Show("恭喜4等奖"); break;
                    case 4: MessageBox.Show("恭喜5等奖"); break;
                    case 5: MessageBox.Show("恭喜6等奖"); break;
                    case 6: MessageBox.Show("恭喜7等奖"); break;
                    case 7: MessageBox.Show("恭喜8等奖"); break;
                    case 8: MessageBox.Show("恭喜9等奖"); break;
                    case 9: MessageBox.Show("恭喜10等奖"); break;
                    default: break;
                }
                button1.Enabled = true;
                timer1.Interval = 10;
            }
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Width = 500;
            this.Height = 500;
            button1.Text = "抽奖";
           
            


            
       
        }
        bool b = true;
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            button1.Enabled = false;
            Random r = new Random();
            rd = r.Next(40, 57);
            if (cnt >= 0)
            {
                if (b == true)
                {
                    b = false;
                    return;
                }

                switch (cnt)
                {
                    case 0:  pictureBox1.Location = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y + 10); break;
                    case 1:  pictureBox2.Location = new Point(pictureBox2.Location.X + 10, pictureBox2.Location.Y + 10); break;
                    case 2: pictureBox3.Location = new Point(pictureBox3.Location.X + 10, pictureBox3.Location.Y + 10); break;
                    case 3:  pictureBox4.Location = new Point(pictureBox4.Location.X + 10, pictureBox4.Location.Y + 10); break;
                    case 4:  pictureBox5.Location = new Point(pictureBox5.Location.X + 10, pictureBox5.Location.Y + 10); break;
                    case 5:  pictureBox6.Location = new Point(pictureBox6.Location.X + 10, pictureBox6.Location.Y + 10); break;
                    case 6:  pictureBox7.Location = new Point(pictureBox7.Location.X + 10, pictureBox7.Location.Y + 10); break;
                    case 7:  pictureBox8.Location = new Point(pictureBox8.Location.X + 10, pictureBox8.Location.Y + 10); break;
                    case 8:  pictureBox9.Location = new Point(pictureBox9.Location.X + 10, pictureBox9.Location.Y + 10); break;
                    case 9:  pictureBox10.Location = new Point(pictureBox10.Location.X + 10, pictureBox10.Location.Y + 10); break;
                    default: break;
                }
            }
        }
    }
}
